﻿using System;
using DiffuseEnjoyIdle.Core.Enums;
using DiffuseEnjoyIdle.Core.Helper;

using System;

using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace System.Linq
{
    /// <summary>
    /// 以...开头
    /// </summary>
    public sealed class ExpBuilderStringStartWidth : ExpressionBuilder, IExpressionBuilder
    {
        private static readonly MethodInfo MatchInfo;

        public ExpBuilderStringStartWidth()
        {
            base.OpType = Enum_ConditionType.StartWith;
            base.EndKey = Enum_ConditionType.StartWith.ToString();
        }

        static ExpBuilderStringStartWidth()
        {
            Type typeFromHandle = typeof(string);
            MatchInfo = typeFromHandle.GetMethod(Enum_ConditionType.StartWith.GetDescription(), new Type[] { typeFromHandle });
        }

        protected override Expression GenExp(Expression left, Expression right)
        {
            return Expression.Call(left, MatchInfo, new Expression[] { right });
        }
    }
}